package com.dzzw.Servlet.UserServlet;

import com.dzzw.Dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/UserRegisterServlet")
public class UserRegisterServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String user_password = request.getParameter("user_password");
        String user_actnumber = request.getParameter("user_actnumber");
        String user_nickname = request.getParameter("user_nickname");
        UserDao userDao = new UserDao();
        userDao.UserRegister(user_password,user_actnumber,user_nickname);
        System.out.println("用户注册成功！");
        response.sendRedirect("/View/UserLogin.jsp");
    }
}
